home *** CD-ROM | disk | FTP | other *** search
- unit Dc_main;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Classes, Graphics, Controls,
- Forms, Dialogs, Menus, StdCtrls, ShellAPI, ExtCtrls,
- Dc_about, Dc_dlog, Cut_sub, IniFiles;
-
- type
- TForm1 = class(TForm)
- OpenDialog1: TOpenDialog;
- MainMenu1: TMainMenu;
- File1: TMenuItem;
- Exit1: TMenuItem;
- N1: TMenuItem;
- PrintSetup1: TMenuItem;
- Print1: TMenuItem;
- N2: TMenuItem;
- Open1: TMenuItem;
- KE1: TMenuItem;
- KG1: TMenuItem;
- K1: TMenuItem;
- KS1: TMenuItem;
- N3: TMenuItem;
- Timer1: TTimer;
- sj1: TMenuItem;
- KD1: TMenuItem;
- KC1: TMenuItem;
- Button1: TButton;
- Button2: TButton;
- Button3: TButton;
- Button4: TButton;
- Button5: TButton;
- Button6: TButton;
- Button7: TButton;
- Panel1: TPanel;
- Label1: TLabel;
- ScrollBar1: TScrollBar;
- Button8: TButton;
- Button9: TButton;
- N4: TMenuItem;
- K2: TMenuItem;
- N11: TMenuItem;
- N21: TMenuItem;
- N31: TMenuItem;
- N41: TMenuItem;
- N51: TMenuItem;
- N61: TMenuItem;
- FontDialog1: TFontDialog;
- KEditer1: TMenuItem;
- FindDialog1: TFindDialog;
- N5: TMenuItem;
- K3: TMenuItem;
- K4: TMenuItem;
- Image1: TImage;
- K5: TMenuItem;
- Panel2: TPanel;
- Label2: TLabel;
- Image2: TImage;
- PrintDialog1: TPrintDialog;
- PrinterSetupDialog1: TPrinterSetupDialog;
- K6: TMenuItem;
- KS2: TMenuItem;
- N6: TMenuItem;
- S1: TMenuItem;
- N1624DotPare1: TMenuItem;
- N1216DotPare1: TMenuItem;
- H1: TMenuItem;
- procedure Open1Click(Sender: TObject);
- procedure Exit1Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- procedure Timer1Timer(Sender: TObject);
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- procedure Button3Click(Sender: TObject);
- procedure Button4Click(Sender: TObject);
- procedure Button8Click(Sender: TObject);
- procedure Button9Click(Sender: TObject);
- procedure Button7Click(Sender: TObject);
- procedure ScrollBar1Scroll(Sender: TObject; ScrollCode: TScrollCode;
- var ScrollPos: Integer);
- procedure K2Click(Sender: TObject);
- procedure N21Click(Sender: TObject);
- procedure N11Click(Sender: TObject);
- procedure N31Click(Sender: TObject);
- procedure N41Click(Sender: TObject);
- procedure N51Click(Sender: TObject);
- procedure N61Click(Sender: TObject);
- procedure KEditer1Click(Sender: TObject);
- procedure K3Click(Sender: TObject);
- procedure K4Click(Sender: TObject);
- procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- procedure K5Click(Sender: TObject);
- procedure Button5Click(Sender: TObject);
- procedure Button6Click(Sender: TObject);
- procedure KS1Click(Sender: TObject);
- procedure KG1Click(Sender: TObject);
- procedure FindDialog1Find(Sender: TObject);
- procedure K1Click(Sender: TObject);
- procedure KS2Click(Sender: TObject);
- procedure N1624DotPare1Click(Sender: TObject);
- procedure N1216DotPare1Click(Sender: TObject);
- procedure KM1Click(Sender: TObject);
- procedure KK1Click(Sender: TObject);
- procedure KH1Click(Sender: TObject);
- procedure FormClose(Sender: TObject; var Action: TCloseAction);
- procedure H1Click(Sender: TObject);
- private
- { Private 宣言 }
- public
- { Public 宣言 }
- end;
-
- var
- Form1: TForm1;
- isLoad: Integer;
- currentFileName: String;
- currentPath: String;
- currentFileLine: Longint;
- a_Path, b_Path, c_Path: String;
- recordFileName: Array [0..10] of String;
- recordPath: Array [0..10] of String;
- recorddispline: Array [0..10] of Integer;
- depth: Integer;
- mbtn: Integer;
- sFontHight, sFontWidth, lFontHight, lFontWidth: Integer;
- sFontSize, lFontSize: Integer;
- scroll, step: Integer;
- displine: Longint;
- picFlag, edtFlag: Integer;
- picProg, picParam, edtProg, edtParam: String;
- memoDiv: Longint;
- dcvError, useMemo2: integer;
- isBmpCreate: Integer;
- winRc, srcRc1, dstRc1, rgnRc1: TRect;
- srcRc2, dstRc2, rgnRc2: TRect;
- cutBmpArray: Array [0..40] of TBitMap;
- cutExe: Array [0..40] of Integer;
- cutNo: Integer;
- dispCut: Integer;
- txtHdl: THandle;
- dcLine: Array [0..9999] of Pointer;
- dcSize: Longint;
- pastline: Longint;
- dcBmp: TBitMap;
- dcBmpOk: Integer;
- slFontType: String;
- FontSize: Integer;
- ownPath: String;
- function loadText(name: String):Boolean;
- function drawText(dispLine: Longint; dmode: Integer): boolean;
- function pickupPath(name: String): Boolean;
- function nextFile(comline, nextFileName: String): boolean;
- function changePath(name: String): String;
- function structName(name: String): String;
- function returnDoc(dispmode: Integer): Boolean;
- function escChange(escCode: Integer): Boolean;
- function setConditions(escCode: Integer): Boolean;
- function setCondition2(escCode2: Integer): Boolean;
- function fock(fockFileName, Params, DefaultDir: String): Integer;
- function isKanji(ck: Char): Integer;
- function isKigou(cc: Char): Integer;
- function isExcept(ce: String): Integer;
- function findTextDown(sTxt: String): Boolean;
- function findTextUp(sTxt: String): Boolean;
- function drawSLine(ll: Longint): Boolean;
- function SetIni(ini: String): Boolean;
- function CheckScroll(qc:Integer): Boolean;
- function SetLargeFont(FS1:Integer):Boolean;
- function SetSmallFont(FS2:Integer):Boolean;
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.Open1Click(Sender: TObject);
- begin
- if OpenDialog1.Execute then
- begin
- { FileOpenDialog }
- currentFileName := OpenDialog1.FileName;
- loadText(currentFileName);
- if (dcvError>0) then
- begin
- dcvError := 0;
- exit;
- end;
- drawText(displine, 0);
- end;
- end;
-
- function loadText(name: String):Boolean;
- var
- exbuff: Array [1..2048] of char;
- buff: Array [1..4] of String[255];
- ori, dpos, cpos, jpos, cutSubNo: Integer;
- fl, blen, gyou, retu, ret, fileHdl: Longint;
- cf: file of byte;
- theLine: String;
- theChar: Char;
- memoCount, memo2Flag, cfl: Longint;
- sbuff, sbuf2, cutName: String;
-
- dmyPtr: PChar;
- dmyHdl: THandle;
- txtPt, txtTop, txtRes, txtBuf: PChar;
- i, ii, j, jj, line_count: Longint;
- vw, txt_end, zen, tb, esc, err, cutOk, pgb, barMax, fpos: Integer;
- cut_lno: Char;
- fbuff, fbuff2, dmyfname: String;
- pat1, msg: String;
- barRc: TRect;
- begin
- { Save CurrentPath }
- currentPath := ExtractFilePath(currentFileName);
- if (AnsiUpperCase(ExtractFileName(currentFileName)) = 'MOKUJI.DOC') then
- pickupPath(currentFileName);
- { Disable MainForm } {
- form1.enabled := False; }
- { CheckName }
- currentFileName := AnsiUpperCase(currentFileName);
- currentFileName := AnsiUpperCase(currentFileName);
- fbuff := ExtractFileName(currentFileName);
- if (Length(fbuff) > 12) then
- begin
- fpos := Pos('.', fbuff);
- if (fpos > 0) then
- begin
- fbuff2 := Copy(fbuff, 1, 8);
- fbuff := fbuff2 + Copy(fbuff, fpos, 4);
- fbuff2 := ExtractFilePath(currentFileName);
- currentFileName := fbuff2 + fbuff;
- end;
- end;
- { File is There? }
- if FileExists(currentFileName) = False then
- begin
- msg := '"' + currentFileName + '"' + 'が見つかりません!';
- MessageDlg(msg, mtError, [mbOK], 0);
- dcvError := 1;
- { Enable MainForm }
- form1.enabled := True;
- exit;
- end;
- { Iregal FileType }
- if (ExtractFileExt(currentFileName) = '.X')
- Or (ExtractFileExt(currentFileName) = '.Z')
- Or (ExtractFileExt(currentFileName) = '.R')
- Or (ExtractFileExt(currentFileName) = '.EXE')
- Or (ExtractFileExt(currentFileName) = '.COM') then
- begin
- msg := '"' + currentFileName + '"' + 'このファイルは読み込めません!';
- MessageDlg(msg, mtError, [mbOK], 0);
- dcvError := 1;
- { Enable MainForm }
- form1.enabled := True;
- exit;
- end;
- { Iregal FileName}
- theline := ExtractFileName(currentFileName);
- if (Length(ExtractFileName(currentFileName)) > 12) then
- begin
- msg := '"' + currentFileName + '"' + 'ファイル名が異常です!';
- MessageDlg(msg, mtError, [mbOK], 0);
- dcvError := 1;
- { Enable MainForm }
- form1.enabled := True;
- exit;
- end;
- { Reset Values }
- memoCount := 0;
- displine := 0;
- currentFileLine := 0;
- AssignFile(cf, currentFileName);
- FileMode := 0;
- Reset(cf);
- fl := FileSize(cf);
- Close(cf);
- { FileSize Too Large? }
- if (fl > 2*1024*1024) then
- begin
- MessageDlg('ファイルサイズが大きすぎます!', mtError, [mbOK], 0);
- dcvError := 1;
- { Enable MainForm }
- form1.enabled := True;
- exit;
- end;
- dcSize := fl;
- dmyHdl := GlobalAlloc(GMEM_DISCARDABLE+GMEM_MOVEABLE+GMEM_ZEROINIT, fl + 1024);
- if (dmyHdl = 0) then
- begin
- MessageDlg('メモリが確保できません!', mtError, [mbOK], 0);
- dcvError := 1;
- { Enable MainForm }
- form1.enabled := True;
- exit;
- end;
- GlobalFree(dmyHdl);
- { Get GlobalMemory }
- if (isLoad = 1) then
- GlobalFree(txtHdl);
- txtHdl := GlobalAlloc(GMEM_DISCARDABLE+GMEM_MOVEABLE+GMEM_ZEROINIT, fl + 1024);
- { Set Cursor crHourGlass }
- screen.cursor := crHourGlass;
- { Disable Control }
- form1.File1.Enabled := False;
- form1.KE1.Enabled := False;
- form1.K6.Enabled := False;
- form1.sj1.Enabled := False;
- form1.button1.enabled := False;
- form1.button2.enabled := False;
- form1.button3.enabled := False;
- form1.button4.enabled := False;
- form1.button5.enabled := False;
- form1.button6.enabled := False;
- form1.button8.enabled := False;
- form1.button9.enabled := False;
- form1.scrollbar1.enabled := False;
- form1.KE1.enabled := False;
- form1.KEditer1.enabled := False;
- form1.H1.enabled := False;
- if (depth > 0) then
- form1.button7.enabled := False;
- { LockGlobalBlock }
- txtPt := GlobalLock(txtHdl);
- txtRes := txtPt;
- txtTop := txtPt;
- { Read File To txtHdl }
- fileHdl := FileOpen(currentFileName, OF_SHARE_COMPAT);
- FileRead(fileHdl, txtPt^, fl);
- FileClose(fileHdl);
- { Count LineNumber }
- currentFileLine := 0;
- line_count := 1;
- cutNo := 0;
- pgb := 0;
- while (1=1) do
- begin
- j := 0;
- jj := 0;
- vw := 0;
- dcLine[line_count] := Pointer(Longint(txtPt) - Longint(txtTop));
- txt_end := 0;
- zen := 1;
- while (1=1) do
- begin
- if (txtPt^ = Chr(26)) Or (txtPt^ = Chr(0)) then { EOF }
- begin
- txtPt^ := Chr(0);
- txt_end := 1;
- break;
- end;
-
- if (txtPt^ = Chr(13)) then { 改行処理 }
- begin
- Inc(txtPt, 1);
- break;
- end;
-
- if (txtPt^ = Chr(10)) then { LF処理 }
- begin
- Inc(txtPt, 1);
- dcLine[line_count] := Pointer(Longint(txtPt) - Longint(txtTop));
- continue;
- end;
-
- if (txtPt^ = Chr(9)) then { TAB処理 }
- begin
- tb := 8 - (jj Mod 8);
- j := 0;
- jj := jj + tb;
- Inc(txtPt, 1);
- zen := 0;
- continue;
- end;
-
- if (txtPt^ = Chr(27)) then { esc文字属性 }
- begin
- if ((txtPt+1)^ = '[') then
- begin
- esc := 0;
- txtPt := txtPt + 2;
- while (txtPt^ <> 'm') do
- Inc(txtPt, 1);
- Inc(txtPt, 1);
- continue;
- end;
- end;
-
- if (jj = 94) then { 行の折り返し }
- begin
- pat1 :='';
- pat1 := txtPt^;
- pat1 := pat1 + (txtPt + 1)^;
- if (isExcept(pat1) = 1) then
- begin
- Inc(txtPt, 2);
- if (txtPt^ = Chr(13)) then
- begin
- Inc(txtPt, 1);
- break;
- end;
- end;
- end;
-
- if (jj > 94) then
- break;
-
- if (isKanji(txtPt^) = 1) then { 漢字 }
- begin
- Inc(txtPt, 2);
- Inc(jj, 2);
- continue;
- end;
-
- if (txtPt^ = '%') then { %コード処理 }
- begin
- if ((txtPt + 1)^ = 'V') then { 倍角設定 }
- begin
- vw := 1;
- Inc(txtPt, 4);
- j := 0;
- continue;
- end;
-
- if ((txtPt + 1)^ = 'C') And (dispCut = 1) And (cutNo < 30) then
- begin
- if ((txtPt + 4)^ = ':') then { カットファイル }
- begin
- { Show ProgressBar }
- if (pgb = 0) then
- begin
- barRc := Rect(0, 0, 233, 17);
- barMax := fl div 10;
- form1.panel2.visible := True;
- form1.image2.canvas.brush.Color := clBlack;
- form1.image2.canvas.FrameRect(barRc);
- form1.image2.canvas.brush.Color := clWhite;
- barRc := Rect(1, 1, 233-1, 17-1);
- form1.image2.canvas.FillRect(barRc);
- form1.image2.canvas.brush.Color := clBlue;
- pgb := 1;
- end;
- txtBuf := txtPt;
- Inc(cutNo, 1);
- cut_lno := '1';
- (txtPt+2)^ := Chr(Ord('0') + cutNo);
- (txtPt+3)^ := cut_lno;
- Inc(txtPt, 5);
- while (isKigou(txtPt^) = 1) do
- Inc(txtPt, 1);
- dmyfname := '';
- for i:=0 to 90-1 do
- begin
- if (txtPt^ = '.') then
- break;
- dmyfname := dmyfname + txtPt^;
- Inc(txtPt, 1);
- end;
- for ii:=i to i+3 do
- begin
- dmyfname := dmyfname + txtPt^;
- Inc(txtPt, 1);
- end;
- cutName := structName(dmyfname);
- { Get Bitmap }
- if (cutExe[cutNo] = 1) then cutBmpArray[cutNo].free;
- cutBmpArray[cutNo] := TBitmap.create;
- cutExe[cutNo] := cut_sub.cutSub(cutName, cutBmpArray[cutNo]);
- err := cutExe[cutNo];
- if (err = 0) then
- begin
- cutOk := 0;
- txtPt := txtBuf;
- (txtPt+2)^ := 'U';
- (txtPt+3)^ := 'T';
- end;
- if (err = 1) then
- begin
- cutOk := 1;
- continue;
- end;
- end;
- if (cutOk = 1) then
- begin
- (txtPt+2)^ := Chr(Ord('0') + cutNo);
- Inc(cut_lno, 1);
- (txtPt+3)^ := cut_lno;
- end;
- end;
- end;
-
- if (txtPt^ = Chr(24)) then { 倍角解除 }
- begin
- if (vw = 1) then
- begin
- vw := 0;
- j := 0;
- continue;
- end;
- Inc(txtPt, 1);
- continue;
- end;
-
- Inc(txtPt, 1); { Normal String }
- Inc(jj ,1);
- end;
- if (txt_end = 1) then break;
- if ((Longint(txtPt) - Longint(txtTop) + 1) >= fl) then break;
- Inc(line_count, 1);
- { Do ProgressBar }
- if (pgb > 0) then
- begin
- barRc.Right := 3 + (23 *(Longint(txtPt) - Longint(txtTop) + 1)) div barmax;
- form1.image2.canvas.FillRect(barRc);
- end;
- Application.ProcessMessages;
- end;
- { Del ProgressBar }
- if (pgb > 0) then
- begin
- form1.panel2.visible := False;
- end;
- currentFileLine := line_count;
- { Replace WindowTitle }
- form1.Caption :='DC_VIEW ['+ExtractFileName(currentFileName)+']';
- form1.scrollbar1.position := 0;
- if (currentFileLine - 30 < 0) then
- form1.scrollbar1.max := 0
- else
- form1.scrollbar1.max := currentFileLine - 30;
- { File Loaded }
- isLoad := 1;
- { Enable Control }
- form1.File1.Enabled := True;
- form1.KE1.Enabled := True;
- form1.K6.Enabled := True;
- form1.sj1.Enabled := True;
- form1.button1.enabled := True;
- form1.button2.enabled := True;
- form1.button3.enabled := True;
- form1.button4.enabled := True;
- form1.button5.enabled := True;
- form1.button6.enabled := True;
- form1.button8.enabled := True;
- form1.button9.enabled := True;
- form1.scrollbar1.enabled := True;
- form1.KE1.enabled := True;
- form1.KEditer1.enabled := True;
- form1.H1.enabled := True;
- if (depth > 0) then
- form1.button7.enabled := True;
- { UnlockGlobalBlock }
- GlobalUnlock(txtHdl);
- { Enable MainForm } {
- form1.enabled := True; }
- end;
-
- procedure TForm1.Exit1Click(Sender: TObject);
- var
- i: Integer;
- begin
- if (isLoad = 1) then
- GlobalFree(txtHdl);
- for i:=1 to 40 do
- begin
- if (cutExe[i] = 1) then
- cutBmpArray[i].Free;
- end;
- close;
- end;
-
- function drawText(dispLine: Longint; dmode: Integer): boolean;
- var buff, buff2, buff3: String;
- moji: Char;
- dcutNo, dcutRc: Integer;
- i, j, k, l, done, spos, lpos, x, y, sl, el, esc, tmp, linelen, dmyLen: Integer;
- cutToRc, cutFrRc: Trect;
-
- jj, vw, zen, tb, istop: Integer;
- txtPt : PChar;
- lineBuff: PChar;
- pat1: String;
- begin
- { Get LineBuffer Memory }
- GetMem(lineBuff, 256);
- { File Already Loaded? }
- if isLoad = 0 then exit;
- { Disp AllLines }
- if (dmode = 0) then
- begin
- form1.image1.canvas.FillRect(winRc);
- sl := 0;
- el := 30;
- end;
- { Disp Scroll }
- if (dmode <> 0) then
- begin
- if (scroll = 1) then
- begin
- sl := 30 - step - 1;
- el := 30;
- form1.image1.canvas.CopyRect(dstRc1, form1.image1.canvas, srcRc1);
- form1.image1.canvas.FillRect(rgnRc1);
- end;
- if (scroll = -1) then
- begin
- sl := 0;
- el := step + 1;
- form1.image1.canvas.CopyRect(dstRc2, form1.image1.canvas, srcRc2);
- form1.image1.canvas.FillRect(rgnRc2);
- end;
- end;
- { LockGlobalBlock }
- txtPt := GlobalLock(txtHdl);
- txtPt := Pointer(Longint(txtPt) + Longint(dcLine[displine+sl+1]));
- { Draw Lines }
- for i:=sl to el do
- begin
- if (currentFileLine < (displine + i)) then break;
- j := 0;
- jj := 0;
- vw := 0;
- zen := 1;
- x := 0;
- y := i * sFontHight;
- while (1=1) do
- begin
- if (txtPt^ = Chr(13)) then { 改行処理 }
- begin
- lineBuff[j] := Chr(0);
- Inc(txtPt, 1);
- break;
- end;
-
- if (txtPt^ = Chr(10)) then { LF処理 }
- begin
- Inc(txtPt, 1);
- continue;
- end;
-
- if (txtPt^ = Chr(9)) then { TAB処理 }
- begin
- tb := 8 - (jj Mod 8);
- lineBuff[j] := Chr(0);
- if (j > 0) then
- form1.image1.canvas.TextOut( x, y, StrPas(lineBuff));
- Inc(x, (tb + Strlen(lineBuff)) * sFontWidth);
-
- j := 0;
- jj := jj + tb;
- Inc(txtPt, 1);
- zen := 0;
- continue;
- end;
-
- if (txtPt^ = Chr(27)) then { esc文字属性 }
- begin
- if ((txtPt+1)^ = '[') then
- begin
- buff2 := '';
- esc := 0;
- Inc(txtPt, 2);
- while ((txtPt^ <> 'm') And (txtPt^ <> 'C')) do
- begin
- buff2:= buff2 + txtPt^;
- Inc(esc, 1);
- Inc(txtPt, 1);
- end;
-
- if (esc <> 0) then { esc設定 }
- begin
- if (txtPt^ = 'C') then { Incert Spaxce }
- begin
- esc := StrToInt(buff2);
- Inc(x, esc * sFontWidth);
- Inc(txtPt, 1);
- j := 0;
- continue;
- end;
- esc := StrToInt(buff2);
- lineBuff[j] := Chr(0);
- form1.image1.canvas.TextOut( x, y, StrPas(lineBuff));
- Inc(x, Strlen(lineBuff) * sFontWidth);
-
- escChange(esc);
-
- Inc(txtPt, 1);
- j := 0;
- continue;
- end;
-
- if (esc = 0) then
- begin
- lineBuff[j] := Char(0);
- form1.image1.canvas.TextOut( x, y, StrPas(lineBuff));
- Inc(x, Strlen(lineBuff) * sFontWidth);
-
- escChange(33);
-
- Inc(txtPt, 1);
- j := 0;
- continue;
- end;
- end;
- end;
-
- if (jj = 94) then { 行の折り返し }
- begin
- pat1 := '';
- pat1 := pat1 + txtPt^;
- pat1 := pat1 + (txtPt+1)^;
- if (isExcept(pat1) = 1) then
- begin
- lineBuff[j] := txtPt^;
- Inc(j, 1);
- Inc(txtPt, 1);
- lineBuff[j] := txtPt^;
- Inc(j, 1);
- Inc(txtPt, 1);
- end;
- if (txtPt^ = Chr(13)) then
- Inc(txtPt, 1);
- lineBuff[j] := Chr(0);
- break;
- end;
-
- if (jj > 94) then
- begin
- lineBuff[j] := Chr(0);
- break;
- end;
-
- if (isKanji(txtPt^) = 1) then { 漢字 }
- begin
- lineBuff[j] := txtPt^;
- Inc(txtPt, 1);
- Inc(j, 1);
- lineBuff[j] := txtPt^;
- Inc(txtPt, 1);
- Inc(j, 1);
- Inc(jj, 2);
- continue;
- end;
-
- if (txtPt^ = '%') then { %コード処理 }
- begin
- if ((txtPt + 1)^ = 'V') then { 倍角設定 }
- begin
- vw := 1;
- Inc(txtPt, 4);
- lineBuff[j] := Chr(0);
- form1.image1.canvas.TextOut( x, y, StrPas(lineBuff));
- Inc(x, Strlen(lineBuff) * sFontWidth);
-
- j := 0;
- continue;
- end;
- if (((txtPt + 1)^ = 'C') And ((txtPt+2)^ <> 'U')) then
- begin { カットファイル }
- dcutNo := Ord((txtPt+2)^) - 48;
- dcutRc := Ord((txtPt+3)^) - 49;
- istop := 0;
- if ((txtPt+4)^ = ':') then
- begin
- while (txtPt^ <> '.') do
- Inc(txtPt, 1);
- Inc(txtPt, 4);
- istop := 1;
- end;
- if (istop = 0) then
- begin
- Inc(txtPt, 4);
- end;
- if (j>0) then
- begin
- lineBuff[j] := Chr(0);
- form1.image1.canvas.TextOut( x, y, StrPas(lineBuff));
- Inc(x, Strlen(lineBuff) * sFontWidth);
-
- j := 0;
- end;
- { Draw CutFile }
- if ((dcutRc + 1) * 16 > cutBmpArray[dcutNo].Height) then
- begin
- cutFrRc := Rect(0, dcutRc * 16, cutBmpArray[dcutNo].Width, cutBmpArray[dcutNo].Height);
- cutToRc := Rect(x, y, x + (cutBmpArray[dcutNo].Width * sFontWidth) Div 8,
- y + ((cutBmpArray[dcutNo].Height - dcutRc * 16 + 1) * sFontWidth) Div 8);
- end;
- if ((dcutRc + 1) * 16 <= cutBmpArray[dcutNo].Height) then
- begin
- cutFrRc := Rect(0, dcutRc * 16, cutBmpArray[dcutNo].Width, (dcutRc + 1) * 16);
- cutToRc := Rect(x, y, x + (cutBmpArray[dcutNo].Width * sFontWidth) Div 8, y + sFontHight);
- end;
- form1.image1.canvas.CopyRect(cutToRc, cutBmpArray[dcutNo].canvas, cutFrRc);
- Inc(x, (cutBmpArray[dcutNo].Width * sFontWidth) Div 8);
- continue;
- end;
- end;
-
- if (txtPt^ = Chr(24)) then { 倍角解除 }
- begin
- if (vw = 1) then
- begin
- lineBuff[j] := Chr(0);
- form1.image1.canvas.Font.Size := lFontSize;
- y := y + 4;
-
- form1.image1.canvas.TextOut( x, y, StrPas(lineBuff));
- Inc(x, Strlen(lineBuff) * sFontWidth);
-
-
- form1.image1.canvas.Font.Size := sFontSize;
- y := y - 4;
-
- vw := 0;
- jj := jj + j Div 2;
- Inc(x, (j Div 2) * sFontWidth);
-
- j := 0;
- Inc(txtPt, 1);
- continue;
- end;
- Inc(txtPt, 1);
- continue;
- end;
-
- lineBuff[j] := txtPt^;
- Inc(j, 1);
- Inc(txtPt,1);
- lineBuff[j] := Chr(0);
-
- Inc(jj, 1);
- end;
-
- if (vw = 1) then
- begin
- form1.image1.canvas.Font.Size := lFontSize;
- y := y + 4;
- end;
- form1.image1.canvas.TextOut( x, y, StrPas(lineBuff));
- Inc(x, Strlen(lineBuff) * sFontWidth);
- if (vw = 1) then
- begin
- form1.image1.canvas.Font.Size := sFontSize;
- y := y - 4;
- vw := 0;
- end;
- esc := 33;
- escChange(esc);
- end;
- { UnlockGlobalBlock }
- GlobalUnlock(txtHdl);
- { Free LineBffer Memory }
- FreeMem(lineBuff, 256);
- { Set ScrollBar & DisplayPosition }
- form1.scrollbar1.position := displine;
- Str(displine, buff);
- buff2 := '';
- for i:=1 to 5-Length(buff) do
- buff2 := buff2 + ' ';
- buff2 := buff2 + buff;
- form1.label1.caption := buff2;
- { Set Cursor crHourGlass }
- screen.cursor := crArrow;
- end;
-
- function escChange(escCode: Integer): Boolean;
- var
- escColor, fc: Integer;
- begin
- { Change FontColor }
- escColor := (escCode Mod 10) Mod 4;
- case escColor of
- 0: form1.image1.canvas.font.color := clGreen;
- 1: form1.image1.canvas.font.color := clAqua;
- 2: form1.image1.canvas.font.color := clFuchsia;
- 3: form1.image1.canvas.font.color := clWhite;
- end;
- { Change FontStyle }
- if escCode < 34 then
- begin
- form1.image1.canvas.Font.Style := [];
- form1.image1.canvas.Font.Size := sFontSize;
- exit;
- end;
- if escCode < 38 then
- begin
- form1.image1.canvas.Font.Style := [fsBold];
- form1.image1.canvas.Font.Size := sFontSize - 1;
- exit;
- end;
- if escCode < 44 then
- begin
- form1.image1.canvas.Font.Style := [fsItalic];
- form1.image1.canvas.Font.Size := sFontSize;
- exit;
- end;
- if escCode >= 44 then
- begin
- form1.image1.canvas.Font.Style := [fsBold]+[fsItalic];
- form1.image1.canvas.Font.Size := sFontSize - 1;
- end;
- end;
-
- function setConditions(escCode: Integer): Boolean;
- begin
- form1.image1.canvas.Font.Size := sFontSize;
- form1.image1.canvas.brush.color := clGreen;
- form1.image1.canvas.font.color := clWhite;
- form1.image1.canvas.Font.Style := [];
- end;
- function setCondition2(escCode2: Integer): Boolean;
- begin
- srcRc1 := Rect(0, step*sFontHight, form1.clientwidth, form1.clientheight-18);
- dstRc1 := Rect(0, 0, form1.clientwidth, form1.clientheight-18-step*sFontHight);
- rgnRc1 := Rect(0, form1.clientheight-18-step*sFontHight, form1.clientwidth, form1.clientheight-18);
- srcRc2 := Rect(0, 0, form1.clientwidth,form1.clientheight-18-step*sFontHight);
- dstRc2 := Rect(0, step*sFontHight, form1.clientwidth,form1.clientheight-18);
- rgnRc2 := Rect(0, 0, form1.clientwidth, step*sFontHight);
- end;
-
- function pickupPath(name: String): Boolean;
- var
- dpos, dpos1, dpos2: Integer;
- buff, buff2: String;
- begin
- buff := ExtractFilePath(currentFileName);
- buff2 := '';
- { Search Directory }
- dpos1 := Pos('QS', buff);
- if (dpos1 > 0) then
- buff2 := Copy(buff, 1, dpos1 - 1);
- dpos2 := Pos('QUICKSTA', buff);
- if (dpos2 > 0) then
- buff2 := Copy(buff, 1, dpos2 - 1);
- if (dpos1 = 0) And (dpos2 = 0) then buff2 := buff;
- a_Path := Copy(buff2, 1, Length(buff2) - 1);
- { B,C Path Setting }
- dpos :=Pos('A\', buff2);
- if (dpos > 0) then
- begin
- buff2[dpos] := 'B';
- b_Path := Copy(buff2, 1, Length(buff2) - 1);
- dpos :=Pos('B\', buff2);
- buff2[dpos] := 'C';
- c_Path := Copy(buff2, 1, Length(buff2) - 1);
- exit;
- end;
- dpos :=Pos('1\', buff2);
- if (dpos > 0) then
- begin
- buff2[dpos] := '2';
- b_Path := Copy(buff2, 1, Length(buff2) - 1);
- dpos :=Pos('2\', buff2);
- buff2[dpos] := '3';
- c_Path := Copy(buff2, 1, Length(buff2) - 1);
- end;
- end;
-
- function nextFile(comline, nextFileName: String): boolean;
- var
- buff, buff2, buff3, buffPath: String;
- docName, exeName, pathName: String;
- dpos, epos, i, j: Integer;
- comPos, execFlag: Integer;
- begin
- buff := Copy(comline, 1, 2);
- { Comannd Exist? }
- if (CompareText(buff, '◎') = 0) then
- begin
- { PickUp Command }
- comPos := Pos('TYPE=', comline);
- if (comPos = 0) then exit;
- buff2 := Copy(comline, comPos, Length(comline) - comPos + 1);
- { Select Type }
- buff3 := Copy(Buff2, 6, 3);
- if (CompareText(buff3, 'DCV') = 0) then
- { Load NextFileName }
- begin
- { Push CurrentFile }
- recordFileName[depth] := currentFileName;
- recorddispline[depth] := displine;
- recordPath[depth] := currentPath;
- depth := depth + 1;
- { Get NextFile & Draw It }
- buff := Copy(buff2, 10, Length(buff2) - 10 + 1);
- for j:=1 to 3 do
- begin
- if (isKigou(buff[j]) = 1) then
- Inc(i, 1)
- else
- break;
- end;
- if (j <> 1) then
- buff := Copy(buff, j, length(buff) - j + 1);
- currentFileName := buff;
- loadText(currentFileName);
- if (dcvError>0) then
- begin
- dcvError := 0;
- returnDoc(0);
- exit;
- end;
- drawText(displine, 0);
- exit;
- end;
-
- if (CompareText(buff3, 'DOC') = 0) then
- { Load NextFileName }
- begin
- { Push CurrentFile }
- recordFileName[depth] := currentFileName;
- recorddispline[depth] := displine;
- recordPath[depth] := currentPath;
- depth := depth + 1;
- { Get NextFile & Draw It }
- buff := Copy(buff2, 10, Length(buff2) - 10 + 1);
- currentFileName := structName(buff);
- loadText(currentFileName);
- if (dcvError>0) then
- begin
- dcvError := 0;
- returnDoc(0);
- exit;
- end;
- drawText(displine, 0);
- exit;
- end;
-
- if (CompareText(buff3, 'EDE') = 0) then
- { Execute PictureLoad & Load NextFile }
- begin
- { Push CurrentFile }
- recordFileName[depth] := currentFileName;
- recorddispline[depth] := displine;
- recordPath[depth] := currentPath;
- depth := depth + 1;
- buff := Copy(buff2, 10, Length(buff2) - 10 + 1);
- { Get DocFileName }
- buff3 := '';
- dpos := 1;
- if (buff[1] = 'C') And (buff[2] = 'D')
- And ((buff[3] = ' ') Or (buff[3] = '=')) then
- begin
- buff2 := Copy(buff, 4, Length(buff) - 4 + 1);
- for i:=1 to Length(buff2) do
- begin
- if (buff2[i] = ':') then
- if (buff2[i+1] <> '\') then
- begin
- buff3 := Copy(buff, 1, 3 + i);
- dpos := i;
- break;
- end;
- end;
- end;
- { Read Command }
- for i:=dpos to Length(buff2) do
- begin
- if (buff2[i] = ':') then
- if (isKigou(buff2[i+1]) = 0) then
- begin
- dpos := i + 1;
- break
- end;
- end;
- for i:=dpos to Length(buff2) do
- begin
- if (buff2[i] = ';') then
- begin
- epos := i - 1;
- break;
- end;
- end;
- exeName := Copy(buff2, dpos, epos - dpos + 1);
- pathName := buff3;
- docName := Copy(buff2, epos + 2, Length(buff2) - epos - 2 + 1);
-
- { Open Picture }
- buff := exeName;
- buff2 := buff;
- if (POS(' 1 JPEGED', buff) > 0) then
- begin
- buff := Copy(buff, POS(' 1 ', buff) + 8, Length(buff) - POS(' 1 ', buff) - 8 + 1);
- end;
- if (POS(' P ', buff) > 0) then
- begin
- buff := Copy(buff, POS(' P ', buff) + 2, Length(buff) - POS(' P ', buff) - 2 + 1);
- end;
- for i:=1 to Length(buff) do
- begin
- if (buff[i] = ' ') And (buff[i+1] <> '/') And (buff[i+1] <> '-') then
- begin
- exeName := Copy(buff, i + 1, Length(buff) - i + 1 + 1);
- break;
- end;
- end;
- if (Pos(':\', exeName) = 0) then
- exeName := structName(buff3 + exeName)
- else
- exeName := structName(exeName);
- if (ExtractFileExt(exeName) = '') then
- begin
- if (compareText(Copy(buff2, 1, 3),'PIC') = 0) then
- exeName := exeName + '.PIC';
- if (compareText(Copy(buff2, 1, 2),'KT') = 0) then
- exeName := exeName + '.PIC';
- if (compareText(Copy(buff2, 1, 3),'JPE') = 0) then
- exeName := exeName + '.JPG';
- end;
- if (picFlag = 1) then
- fock(picProg, exeName, picParam);
- { Open NextFile }
- if (pathName <> '') then
- begin
- buff := structName(pathName + 'a.b');
- buffPath := ExtractFilePath(buff);
- currentPath := buffPath;
- end;
- { StructNewFileName }
- currentFileName := structName(docName);
- if (Pos(';', currentFileName)>0) then
- currentFileName := Copy(currentFileName, 1, length(currentFileName)+Pos(';', currentFileName)-2);
- loadText(currentFileName);
- if (dcvError>0) then
- begin
- dcvError := 0;
- returnDoc(0);
- exit;
- end;
- if (currentPath <> buffPath) And (pathName <> '') then
- currentPath := buffPath;
- drawText(displine, 0);
- exit;
- end;
-
- if (CompareText(buff3, 'EXE') = 0) Or (CompareText(buff3, 'CLI') = 0) then
- { Execute PictureLoad }
- begin
- buff := Copy(buff2, 10, Length(buff2) - 10 + 1);
- { Open Picture }
- if (POS(' 1 JPEGED', buff) > 0) then
- begin
- buff := Copy(buff, POS(' 1 ', buff) + 8, Length(buff) - POS(' 1 ', buff) - 8 + 1);
- end;
- if (POS(' P ', buff) > 0) then
- begin
- buff := Copy(buff, POS(' P ', buff) + 2, Length(buff) - POS(' P ', buff) - 2 + 1);
- end;
- exeName := '';
- for i:=1 to Length(buff) do
- begin
- if (buff[i] = ' ') And (buff[i+1] <> '/') And (buff[i+1] <> '-') then
- begin
- exeName := Copy(buff, i + 1, Length(buff) - i - 1 + 1);
- break;
- end;
- end;
- if (Length(exeName) < 1) then
- begin
- MessageDlg('このファイルは実行できません!', mtError, [mbOK], 0);
- dcvError := 1;
- exit;
- end;
- exeName := structName(exeName);
- execFlag := 0;
- if (Pos('KT ', buff2) > 0) Or (Pos('PIC ', buff2) > 0) Or (Pos('GP11 ', buff2) > 0) then
- begin
- if (ExtractFileExt(exeName) = '') then
- exeName := exeName + '.PIC';
- execFlag := 1;
- end;
- if (Pos('JPEGED ', buff2) > 0) Or (Pos('DJ ', buff2) > 0) then
- begin
- if (ExtractFileExt(exeName) = '') then
- exeName := exeName + '.JPG';
- execFlag := 1;
- end;
- if (execFlag = 1) And (picFlag = 1) then
- fock(picProg, exeName, picParam);
- exit;
- end;
- { Now Abundon Process }
- exit;
- end;
- end;
-
- function changePath(name: String): String;
- var
- buff: String;
- nbuff: Array [0..255] of Char;
- mpos: Integer;
- begin
- { CangeDirectory }
- StrPCopy(nbuff, name);
- if (StrRScan(nbuff, ':') <> nil) then
- StrRScan(nbuff, ':')^ := '\';
- name := StrPas(nbuff);
- if (POS(':+', name) > 0)then
- begin
- mpos := POS(':+', name);
- name[mpos] := '#';
- name[mpos + 1] := '#';
- end;
- if (POS(':*', name) > 0)then
- begin
- mpos := POS(':*', name);
- name[mpos] := '#';
- name[mpos + 1] := '#';
- end;
- While POS('#', name) > 0 do
- begin
- mpos := POS('#', name);
- name := Copy(name, 1, mpos - 1) + Copy(name, mpos + 1, Length(name));
- end;
- buff := Copy(name, 4, Length(name) - 3 + 1);
- changePath := buff;
- end;
-
- function structName(name: String): String;
- begin
- { 'CD' Exist? }
- if (compareText('CD=', Copy(name, 1, 3)) = 0)
- Or (compareText('CD ', Copy(name, 1, 3)) = 0) then
- name := changePath(name);
- if (compareText('CK=', Copy(name, 1, 3)) = 0) then
- name := Copy(name, 6, Length(name) - 6 + 1);
- { Normal Pattern }
- if (compareText('A:\', Copy(name, 1, 3)) = 0) then
- structName := a_Path + Copy(name, 3, Length(name) - 3 + 1)
- else if (compareText('B:\', Copy(name, 1, 3)) = 0) then
- structName := b_Path + Copy(name, 3, Length(name) - 3 + 1)
- else if (compareText('B:', Copy(name, 1, 2)) = 0) then
- structName := b_Path + '\' + Copy(name, 3, Length(name) - 3 + 1)
- else if (compareText('C:\', Copy(name, 1, 3)) = 0) then
- structName := c_Path + Copy(name, 3, Length(name) - 3 + 1)
- else if (name[1] = '\') then
- structName := a_path + name
- else
- structName := currentPath + name;
- name := name;
- end;
-
- function returnDoc(dispmode: Integer): Boolean;
- begin
- scroll := 0;
- if (depth > 0) then
- { Pop FileName }
- begin
- currentFileName := recordFileName[depth-1];
- loadText(currentFileName);
- if (dcvError>0) then
- begin
- dcvError := 0;
- exit;
- end;
- depth := depth - 1;
- currentPath := recordPath[depth];
- displine := recorddispline[depth];
- form1.scrollbar1.position := displine;
- drawText(displine, dispmode);
- if (depth < 1) then
- form1.button7.enabled := False;
- end;
- end;
-
- procedure TForm1.FormCreate(Sender: TObject);
- var
- i: Integer;
- ff: Integer;
- begin
- BorderIcons := BorderIcons - [biMaximize];
- { Set WindowTitle }
- form1.Caption :='DC_VIEW';
- { Initialize Value }
- isLoad := 0;
- depth := 0;
- sFontSize := 9;
- lFontSize := 12;
- sFontHight := 12;
- sFontWidth := 6;
- lFontHight := 16;
- lFontWidth := 8;
- dcvError := 0;
- pastline := 0;
- for i:=0 to 40 do
- cutExe[i] := 0;
- dcBmpOk := 0;
- { Read .INI File }
- if (FileExists('DC_VIEW.INI') = True) then
- begin
- ownPath := ExtractFilePath(ExpandFileName('DC_VIEW.INI'));
- SetIni(ExpandFileName('DC_VIEW.INI'))
- end
- else
- begin
- MessageDlg('DC_VIEW.INIがありません。新しく作成します。',mtError, [mbOK], 0);
- ownPath := ExtractFilePath(ExpandFileName('DC_VIEW.EXE'));
- ff := FileCreate(ownPath + 'DC_VIEW.INI');
- FileClose(ff);
- SetIni(ExpandFileName('DC_VIEW.INI'))
- end;
- { Setup FontSize }
- case FontSize of
- 0:SetSmallFont(0);
- 1:SetLargeFont(0);
- end;
- { SetUp ImageScreen }
- form1.image1.canvas.font.Name := 'MS ゴシック';
- slFontType := 'MS ゴシック';
- form1.image1.canvas.font.pitch := fpFixed;
- isBmpCreate := 1;
- form1.image1.top := 0;
- form1.image1.left := 0;
- { SetUp Window Condition }
- winRc := Rect(0,0,form1.image1.width,form1.image1.height);
- setConditions(0);
- setCondition2(0);
- form1.image1.canvas.FillRect(winRc);
- { Disable Control }
- form1.button1.enabled := False;
- form1.button2.enabled := False;
- form1.button3.enabled := False;
- form1.button4.enabled := False;
- form1.button5.enabled := False;
- form1.button6.enabled := False;
- form1.button7.enabled := False;
- form1.button8.enabled := False;
- form1.button9.enabled := False;
- form1.scrollbar1.enabled := False;
- form1.print1.enabled := False;
- form1.printsetup1.enabled := False;
- form1.KE1.enabled := False;
- form1.KEditer1.enabled := False;
- { Run With Parameters? }
- if (Paramcount > 0) then
- begin
- currentFileName := ParamStr(1);
- loadText(currentFileName);
- if (dcvError>0) then
- begin
- dcvError := 0;
- exit;
- end;
- drawText(displine, 0);
- end;
- Form1.Visible := True;
- { Enable Get DropFileName }
- end;
-
- procedure TForm1.Timer1Timer(Sender: TObject);
- var
- temp: Integer;
- begin
- Timer1.Interval := 10;
- { Scroll? }
- if (scroll = 0) then exit;
- if (scroll = -1) And (displine = 0) then exit;
- if (scroll = 1) And (displine = currentFileLine - 30) then exit;
- { Dshell Scroll }
- if ((displine + scroll * step) < 0) then
- begin
- temp := step;
- step := displine;
- setCondition2(0);
- displine := 0;
- drawText(displine, 1);
- step := temp;
- setCondition2(0);
- exit;
- end;
- if ((displine + scroll * step) > (currentFileLine - 30)) then
- begin
- temp := step;
- step := (currentFileLine - 30) - displine;
- setCondition2(0);
- displine := currentFileLine - 30;
- drawText(displine, 1);
- step := temp;
- setCondition2(0);
- exit;
- end;
- displine := displine + scroll * step;
- drawText(displine, 1);
- end;
-
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- displine := 0;
- drawText(displine, 0);
- { Stop SCroll }
- scroll := 0;
- mbtn := 0;
- end;
-
- procedure TForm1.Button2Click(Sender: TObject);
- begin
- displine := currentFileLine - 30;
- if (displine < 0) then
- displine := 0;
- drawText(displine, 0);
- { Stop SCroll }
- scroll := 0;
- mbtn := 0;
- end;
-
- procedure TForm1.Button3Click(Sender: TObject);
- begin
- displine := displine - 1;
- if (displine < 0) then
- displine := 0;
- drawText(displine, 0);
- { Stop SCroll }
- scroll := 0;
- mbtn := 0;
- end;
-
- procedure TForm1.Button4Click(Sender: TObject);
- begin
- displine := displine + 1;
- if (displine > currentFileLine - 30) then
- displine := currentFileLine - 30;
- drawText(displine, 0);
- { Stop SCroll }
- scroll := 0;
- mbtn := 0;
- end;
-
- procedure TForm1.Button8Click(Sender: TObject);
- begin
- displine := displine - 29;
- if (displine < 30) then
- displine := 0;
- drawText(displine, 0);
- { Stop SCroll }
- scroll := 0;
- mbtn := 0;
- end;
-
- procedure TForm1.Button9Click(Sender: TObject);
- begin
- displine := displine + 29;
- if (displine > currentFileLine - 30) then
- displine := currentFileLine - 30;
- drawText(displine, 0);
- { Stop SCroll }
- scroll := 0;
- mbtn := 0;
- end;
-
- procedure TForm1.Button7Click(Sender: TObject);
- begin
- returnDoc(0);
- { Stop SCroll }
- scroll := 0;
- mbtn := 0;
- end;
-
- procedure TForm1.ScrollBar1Scroll(Sender: TObject; ScrollCode: TScrollCode;
- var ScrollPos: Integer);
- begin
- if (scroll <> 0) then exit;
- displine := scrollbar1.position;
- drawText(displine, 0);
- end;
-
- procedure TForm1.K2Click(Sender: TObject);
- begin
- AboutBox.ShowModal;
- end;
-
- procedure TForm1.N11Click(Sender: TObject);
- begin
- CheckScroll(step);
- step := 1;
- N11.Checked := True;
- setCondition2(0);
- end;
-
- procedure TForm1.N21Click(Sender: TObject);
- begin
- CheckScroll(step);
- step := 2;
- N21.Checked := True;
- setCondition2(0);
- end;
-
- procedure TForm1.N31Click(Sender: TObject);
- begin
- CheckScroll(step);
- step := 3;
- N31.Checked := True;
- setCondition2(0);
- end;
-
- procedure TForm1.N41Click(Sender: TObject);
- begin
- CheckScroll(step);
- step := 4;
- N41.Checked := True;
- setCondition2(0);
- end;
-
- procedure TForm1.N51Click(Sender: TObject);
- begin
- CheckScroll(step);
- step := 5;
- N51.Checked := True;
- setCondition2(0);
- end;
-
- procedure TForm1.N61Click(Sender: TObject);
- begin
- CheckScroll(step);
- step := 6;
- N61.Checked := True;
- setCondition2(0);
- end;
-
- function CheckScroll(qc:Integer): Boolean;
- begin
- case qc of
- 1:Form1.N11.Checked := False;
- 2:Form1.N21.Checked := False;
- 3:Form1.N31.Checked := False;
- 4:Form1.N41.Checked := False;
- 5:Form1.N51.Checked := False;
- 6:Form1.N61.Checked := False;
- end;
- end;
-
- function fock(fockFileName, Params, DefaultDir: String): Integer;
- var
- zFileName, zParams, zDir: array[0..79] of Char;
- begin
- fock := ShellExecute(Form1.Handle, nil,
- StrPCopy(zFileName, fockFileName), StrPCopy(zParams, Params),
- StrPCopy(zDir, DefaultDir), SW_SHOW);
- end;
-
- procedure TForm1.KEditer1Click(Sender: TObject);
- begin
- if (edtFlag = 1) And (isLoad = 1) then
- fock(edtProg, currentFileName, edtParam);
- end;
-
- function isKanji(ck: Char): Integer;
- begin
- if ((ck >= Chr(129)) And (ck <= Chr(159))) Or ((ck >= Chr(224)) And ( ck<= Chr(239))) then
- isKanji := 1
- else
- isKanji := 0;
- end;
-
- function isKigou(cc: Char): Integer;
- begin
- if (Pos(cc, '-+*') > 0) then
- isKigou := 1
- else
- isKigou := 0;
- end;
-
- function isExcept(ce: String): Integer;
- begin
- if (Pos(ce, 'ぁぃぅぇぉゃゅょっゎァィゥェォャュョッヮ'
- +'、。,.?!゛´`‘“)〕]}〉》」』】>') > 0) then
- isExcept := 1
- else
- isExcept := 0;
- end;
-
- procedure TForm1.K3Click(Sender: TObject);
- var
- done: Integer;
- begin
- { Set 起動表示 Window }
- BtnRightDlg.edit1.text := picProg;
- BtnRightDlg.edit2.text := picParam;
- if (picFlag = 0) then
- BtnRightDlg.checkbox1.state := cbUnchecked
- else
- BtnRightDlg.checkbox1.state := cbChecked;
- BtnRightDlg.caption := '画像表示プログラム選択';
- BtnRightDlg.ShowModal;
- if (dc_dlog.can(done) = 1) then exit;
- { SetUp Condition }
- picProg := dc_dlog.retCom(picProg);
- picParam := dc_dlog.retParam(PicParam);
- picFlag := dc_dlog.retpic(picFlag);
- end;
-
- procedure TForm1.K4Click(Sender: TObject);
- var
- done: Integer;
- begin
- { Set 起動表示 Window }
- BtnRightDlg.edit1.text := edtProg;
- BtnRightDlg.edit2.text := edtParam;
- if (edtFlag = 0) then
- BtnRightDlg.checkbox1.state := cbUnchecked
- else
- BtnRightDlg.checkbox1.state := cbChecked;
- BtnRightDlg.caption := 'エディタプログラム選択';
- BtnRightDlg.ShowModal;
- if (dc_dlog.can(done) = 1) then exit;
- { SetUp Condition }
- edtProg := dc_dlog.retCom(edtProg);
- edtParam := dc_dlog.retParam(edtParam);
- edtFlag := dc_dlog.retpic(edtFlag);
- if (edtFlag = 0) then
- form1.KEditer1.enabled := False
- else
- form1.KEditer1.enabled := True;
- end;
-
- procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- var
- buff, buff2: String;
- line, pick: PChar;
- nowPtr, nextPtr, linesize: Longint;
- begin
- { Already Loaded? }
- if isLoad = 0 then exit;
- { ReturnTo PastFile }
- if ((mbtn = 1) And (Button = mbRight))
- or ((mbtn = -1) And (Button = mbLeft)) then
- begin
- returnDoc(0);
- exit;
- end;
- { Command Area? }
- if (Button = mbLeft) And (X < sFontHight) then
- begin
- GetMem(line, 256);
- pick := GlobalLock(txtHdl);
- nowPtr := Longint(dcLine[displine + (y div sFontHight) + 1]);
- nextPtr := Longint(dcLine[displine + (y div sFontHight) + 2]);
- Inc(pick, nowPtr);
- linesize := nextPtr - nowPtr + 1;
- StrMove(line, pick, linesize);
- buff2 := StrPas(line);
- buff2 := Copy(buff2, 1, Pos(Chr(13), buff2) - 1);
- nextFile(buff2, buff);
- GlobalUnlock(txtHdl);
- FreeMem(line, 256);
- exit;
- end;
- { DShell Scroll Start}
- if (Button = mbLeft) then
- if (displine + step > currentFileLine - 30) then
- scroll := 0
- else
- scroll := 1
- else
- if (displine - step < 0) then
- scroll := 0
- else
- scroll := -1;
- { Set ButtonStatus }
- if (Button = mbLeft) then
- mbtn := 1
- else
- mbtn := -1;
-
- end;
-
- procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
- Shift: TShiftState; X, Y: Integer);
- begin
- { Stop SCroll }
- scroll := 0;
- mbtn := 0;
- end;
-
- procedure TForm1.K5Click(Sender: TObject);
- begin
- if (dispCut = 0) then
- begin
- K5.Checked := True;
- dispCut := 1;
- exit;
- end;
- K5.Checked := False;
- dispCut := 0;
- end;
-
- procedure TForm1.Button5Click(Sender: TObject);
- var
- sPtr: PChar;
- i: Integer;
- dep: String;
- begin
- if (isLoad = 0) then exit;
- if (displine <= 1) then exit;
- sPtr := GlobalLock(txtHdl);
- for i:= (displine - 1) downto 1 do
- begin
- dep := '';
- dep := dep + PChar(Longint(sPtr) + Longint(dcLine[i]))^;
- dep := dep + PChar(Longint(sPtr) + Longint(dcLine[i]) + 1)^;
- if (dep = '━') then
- begin
- displine := i - 1;
- drawText(displine, 0);
- break;
- end;
- end;
- GlobalUnlock(txtHdl);
- { Stop SCroll }
- scroll := 0;
- mbtn := 0;
- end;
-
- procedure TForm1.Button6Click(Sender: TObject);
- var
- sPtr: PChar;
- i: Integer;
- dep: String;
- begin
- if (isLoad = 0) then exit;
- if (displine >= currentFileLine - 30) then exit;
- sPtr := GlobalLock(txtHdl);
- for i:= (displine + 2) to currentFileLine do
- begin
- dep := '';
- dep := dep + PChar(Longint(sPtr) + Longint(dcLine[i]))^;
- dep := dep + PChar(Longint(sPtr) + Longint(dcLine[i]) + 1)^;
- if (dep = '━') then
- begin
- displine := i - 1;
- if (displine > currentFileLine - 30) then
- displine := currentFileLine - 30;
- drawText(displine, 0);
- break;
- end;
- end;
- GlobalUnlock(txtHdl);
- { Stop SCroll }
- scroll := 0;
- mbtn := 0;
- end;
-
- procedure TForm1.KS1Click(Sender: TObject);
- begin
- pastline := 0;
- if (isLoad = 0) then exit;
- FindDialog1.Execute;
- end;
-
- function findTextDown(sTxt: String): Boolean;
- var
- sPtr, sLine: PChar;
- i, s1, s2: Longint;
- dep: String;
- begin
- if (isLoad = 0) then exit;
- GetMem(sLine, 256);
- sPtr := GlobalLock(txtHdl);
- for i:= pastline + 1 to currentFileLine-3 do
- begin
- s1 := Longint(sPtr) + Longint(dcLine[i+1]);
- s2 := Longint(dcLine[i+2]) - Longint(dcLine[i+1]) + 1;
- StrMove(sLine, PChar(s1), s2);
- sLine[s2+1] := Chr(0);
- dep := StrPas(sLine);
- if ((form1.FindDialog1.Options*[frMatchCase])<>[frMatchCase]) then
- begin
- sTxt := AnsiUpperCase(sTxt);
- dep := AnsiUpperCase(dep);
- end;
- if (Pos(sTxt, dep) > 0) then
- begin
- displine := i - 15;
- if (displine > currentFileLine - 30) then
- displine := currentFileLine - 30;
- if (displine < 0) then
- displine := 0;
- drawText(displine, 0);
- drawSLine(i);
- pastline := i;
- FreeMem(sLine, 256);
- GlobalUnlock(txtHdl);
- exit;
- end;
- end;
- drawText(displine, 0);
- FreeMem(sLine, 256);
- GlobalUnlock(txtHdl);
- end;
-
- function findTextUp(sTxt: String): Boolean;
- var
- sPtr, sLine: PChar;
- i, s1, s2: Longint;
- dep: String;
- begin
- if (isLoad = 0) then exit;
- GetMem(sLine, 256);
- sPtr := GlobalLock(txtHdl);
- for i:= pastline - 1 downto 0 do
- begin
- s1 := Longint(sPtr) + Longint(dcLine[i+1]);
- s2 := Longint(dcLine[i+2]) - Longint(dcLine[i+1]) + 1;
- StrMove(sLine, PChar(s1), s2);
- sLine[s2+1] := Chr(0);
- dep := StrPas(sLine);
- if ((form1.FindDialog1.Options*[frMatchCase])<>[frMatchCase]) then
- begin
- sTxt := AnsiUpperCase(sTxt);
- dep := AnsiUpperCase(dep);
- end;
- if (Pos(sTxt, dep) > 0) then
- begin
- displine := i - 15;
- if (displine > currentFileLine - 30) then
- displine := currentFileLine - 30;
- if (displine < 0) then
- displine := 0;
- drawText(displine, 0);
- drawSLine(i);
- pastline := i;
- FreeMem(sLine, 256);
- GlobalUnlock(txtHdl);
- exit;
- end;
- end;
- drawText(displine, 0);
- FreeMem(sLine, 256);
- GlobalUnlock(txtHdl);
- end;
-
- function drawSLine(ll: Longint): Boolean;
- var
- ldone, lll: Integer;
- begin
- ldone := 0;
- lll := ll + 1;
- form1.image1.canvas.pen.color := clRed;
- if (ll < 15) then
- begin
- form1.image1.canvas.MoveTo(0, lll * sFontHight);
- form1.image1.canvas.LineTo(form1.clientWidth, lll * sFontHight);
- ldone := 1;
- end;
- if (ll > currentFileLine - 15) then
- begin
- form1.image1.canvas.MoveTo(0, (lll - displine) * sFontHight);
- form1.image1.canvas.LineTo(form1.clientWidth, (lll - displine) * sFontHight);
- ldone := 1;
- end;
- if (ldone = 0) then
- begin
- form1.image1.canvas.MoveTo(0, 16 * sFontHight);
- form1.image1.canvas.LineTo(form1.clientWidth, 16 * sFontHight);
- end;
- form1.image1.canvas.pen.color := clWhite;
- end;
-
- procedure TForm1.KG1Click(Sender: TObject);
- begin
- findTextDown(FindDialog1.FindText);
- end;
-
- procedure TForm1.K1Click(Sender: TObject);
- begin
- findTextUp(FindDialog1.FindText);
- end;
-
- procedure TForm1.FindDialog1Find(Sender: TObject);
- begin
- if ((FindDialog1.Options*[frDown])=[frDown]) then
- findTextDown(FindDialog1.FindText)
- else
- findTextUp(FindDialog1.FindText);
- end;
-
- procedure TForm1.KS2Click(Sender: TObject);
- begin
- FontDialog1.Font := form1.image1.canvas.Font;
- FontDialog1.Font.color := clBlack;
- if FontDialog1.Execute then
- form1.image1.canvas.Font := FontDialog1.Font;
- slFontType := FontDialog1.Font.Name;
- form1.image1.canvas.font.size := sFontSize;
- form1.image1.canvas.font.style := [];
- form1.image1.canvas.font.color := clWhite;
- drawText(displine, 0);
- end;
-
- procedure TForm1.N1624DotPare1Click(Sender: TObject);
- begin
- { Set LargeCharacter }
- SetLargeFont(FontSize);
- FontSize := 1;
- Form1.N1216DotPare1.Checked := False;
- Form1.N1624DotPare1.Checked := True;
- end;
-
- function SetLargeFont(FS1:Integer):Boolean;
- begin
- sFontSize := 12;
- lFontSize := 16;
- sFontHight := 16;
- sFontWidth := 8;
- lFontHight := 24;
- lFontWidth := 12;
- { Set WindowSize }
- if (dcBmpOk = 1) then dcBmp.Free;
- dcBmp := TBitmap.create;
- dcBmpOk := 1;
- dcBmp.height := 480+18;
- dcBmp.width := 768;
- Form1.clientheight := 480+18;
- Form1.clientwidth := 768;
- Form1.Image1.Picture.Graphic := dcBmp;
- form1.image1.canvas.font.size := 12;
- form1.image1.canvas.font.Name := slFontType;
- form1.image1.canvas.font.pitch := fpFixed;
- SetConditions(0);
- SetCondition2(0);
- winRc := Rect(0,0,form1.image1.width,form1.image1.height);
- form1.image1.canvas.FillRect(winRc);
-
- Form1.Button1.Top := 480;
- Form1.Button2.Top := 480;
- Form1.Button3.Top := 480;
- Form1.Button4.Top := 480;
- Form1.Button5.Top := 480;
- Form1.Button6.Top := 480;
- Form1.Button7.Top := 480;
- Form1.Button7.Left := 530+192;
- Form1.Button8.Top := 480;
- Form1.Button9.Top := 480;
- Form1.Panel1.Top := 480;
- Form1.Panel1.Left := 480+192;
- Form1.ScrollBar1.Top := 480;
- Form1.ScrollBar1.Width := 160+192;
- drawText(displine, 0);
- end;
-
- procedure TForm1.N1216DotPare1Click(Sender: TObject);
- begin
- { Set LargeCharacter }
- SetSmallFont(FontSize);
- FontSize := 0;
- Form1.N1216DotPare1.Checked := True;
- Form1.N1624DotPare1.Checked := False;
- end;
-
- function SetSmallFont(FS2:Integer):Boolean;
- begin
- sFontSize := 9;
- lFontSize := 12;
- sFontHight := 12;
- sFontWidth := 6;
- lFontHight := 16;
- lFontWidth := 8;
- { Set WindowSize }
- if (dcBmpOk = 1) then dcBmp.Free;
- dcBmp := TBitmap.create;
- dcBmpOk := 1;
- dcBmp.height := 360+18;
- dcBmp.width := 576;
- Form1.clientheight := 360+18;
- Form1.clientwidth := 576;
- Form1.Image1.Picture.Graphic := dcBmp;
- form1.image1.canvas.font.size := 9;
- form1.image1.canvas.font.Name := slFontType;
- form1.image1.canvas.font.pitch := fpFixed;
- setConditions(0);
- setCondition2(0);
- winRc := Rect(0,0,form1.image1.width,form1.image1.height);
- form1.image1.canvas.FillRect(winRc);
-
- Form1.Button1.Top := 360;
- Form1.Button2.Top := 360;
- Form1.Button3.Top := 360;
- Form1.Button4.Top := 360;
- Form1.Button5.Top := 360;
- Form1.Button6.Top := 360;
- Form1.Button7.Top := 360;
- Form1.Button7.Left := 530;
- Form1.Button8.Top := 360;
- Form1.Button9.Top := 360;
- Form1.Panel1.Top := 360;
- Form1.Panel1.Left := 480;
- Form1.ScrollBar1.Top := 360;
- Form1.ScrollBar1.Width := 160;
- drawText(displine, 0);
- end;
-
- procedure TForm1.KM1Click(Sender: TObject);
- begin
- Application.HelpFile := 'DC_VIEW.HLP';
- Application.HelpCommand(HELP_CONTENTS, 0);
- end;
-
- procedure TForm1.KK1Click(Sender: TObject);
- begin
- Application.HelpFile := 'DC_VIEW.HLP';
- Application.HelpCommand(HELP_PARTIALKEY, 0);
- end;
-
- procedure TForm1.KH1Click(Sender: TObject);
- begin
- Application.HelpFile := 'WINHELP.HLP';
- Application.HelpCommand(HELP_CONTENTS, 0);
- end;
-
- function SetIni(ini: String): Boolean;
- var
- IniFile: TIniFile;
- param: Integer;
- begin
- IniFile := TIniFile.Create(ini);
- With IniFile do
- begin
- { FontSize }
- if ReadString('Font', 'FontSize', 'Small') = 'Small' then
- FontSize := 0
- else
- FontSize := 1;
- case FontSize of
- 0:Form1.N1216DotPare1.Checked := True;
- 1:Form1.N1624DotPare1.Checked := True;
- end;
- { CutFile Disp? }
- if ReadString('Cut', 'Visible', 'False') = 'False' then
- dispCut := 0
- else
- dispCut := 1;
- case dispCut of
- 0:Form1.K5.Checked := False;
- 1:Form1.K5.Checked := True;
- end;
- { ScrollStep }
- param := ReadInteger('Scroll', 'Step', -1);
- if (param < 1) Or (param > 6) then param := 4;
- step := param;
- case step of
- 1:Form1.N11.Checked := True;
- 2:Form1.N21.Checked := True;
- 3:Form1.N31.Checked := True;
- 4:Form1.N41.Checked := True;
- 5:Form1.N51.Checked := True;
- 6:Form1.N61.Checked := True;
- end;
- { Graphic Disp. }
- if ReadString('Graphic', 'Show', 'False') = 'False' then
- picFlag := 0
- else
- picFlag := 1;
- picProg := ReadString('Graphic', 'Program', '');
- picParam := ReadString('Graphic', 'Dir', '');
- { Editer Call }
- if ReadString('Editer', 'Use', 'False') = 'False' then
- edtFlag := 0
- else
- edtFlag := 1;
- edtProg := ReadString('Editer', 'Program', '');
- edtParam := ReadString('Editer', 'Dir', '');
- end;
- IniFile.Free;
- end;
-
- procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
- var
- IniFile: TIniFile;
- param: Integer;
- ini: String;
- begin
- { Global Block Free }
- if (isLoad = 1) then
- GlobalFree(txtHdl);
-
- ini := ownPath + 'DC_VIEW.INI';
- try
- IniFile := TIniFile.Create(ini);
- With IniFile do
- begin
- { FontSize }
- if FontSize = 0 then
- WriteString('Font', 'FontSize', 'Small')
- else
- WriteString('Font', 'FontSize', 'Large');
- { CutFile Disp? }
- if dispCut = 0 then
- WriteString('Cut', 'Visible', 'False')
- else
- WriteString('Cut', 'Visible', 'True');
- { ScrollStep }
- WriteInteger('Scroll', 'Step', step);
- { Graphic Disp. }
- if picFlag = 0 then
- WriteString('Graphic', 'Show', 'False')
- else
- WriteString('Graphic', 'Show', 'True');
- WriteString('Graphic', 'Program', picProg);
- WriteString('Graphic', 'Dir', picParam);
- { Editer Call }
- if edtFlag = 0 then
- WriteString('Editer', 'Use', 'False')
- else
- WriteString('Editer', 'Use', 'True');
- WriteString('Editer', 'Program', edtProg);
- WriteString('Editer', 'Dir', edtParam);
- end;
- IniFile.Free;
- except
- on Exception do
- begin
- MessageBeep(0);
- MessageDlg('DC_VIEW.INIを更新することができませんでした。',mtError, [mbOK], 0);
- end;
- end;
- end;
-
- procedure TForm1.H1Click(Sender: TObject);
- begin
- if (depth = 0) then
- begin
- currentFileName := 'DC_VIEW.DOC';
- loadText(currentFileName);
- if (dcvError>0) then
- begin
- dcvError := 0;
- exit;
- end;
- drawText(displine, 0);
- end
- else
- begin
- { Push CurrentFile }
- recordFileName[depth] := currentFileName;
- recorddispline[depth] := displine;
- recordPath[depth] := currentPath;
- depth := depth + 1;
- currentFileName := 'DC_VIEW.DOC';
-
- loadText(currentFileName);
- if (dcvError>0) then
- begin
- dcvError := 0;
- returnDoc(0);
- exit;
- end;
- drawText(displine, 0);
- end;
- end;
-
- end.
-